package cn.edu.tju.cas.util;

import cn.edu.tju.cas.entity.UserGroupFormValueEntity;
import org.hibernate.mapping.Array;

import java.util.List;
import java.util.Set;

/**
 * 提交申请时，前端 json 提交
 * Created by jack on 2016/3/13.
 */
public class NewApply {
    private int groupId;

    private Set<UserGroupFormValueEntity> userGroupFormValues;

    public NewApply(){

    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public Set<UserGroupFormValueEntity> getUserGroupFormValues() {
        return userGroupFormValues;
    }

    public void setUserGroupFormValues(Set<UserGroupFormValueEntity> userGroupFormValues) {
        this.userGroupFormValues = userGroupFormValues;
    }

    @Override
    public String toString(){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("groupId: " + this.groupId + "\n + userGroupFormValues:[");
        if(userGroupFormValues!=null){
            Object[] formValueEntityArray = userGroupFormValues.toArray();
            for(int i = 0; i<formValueEntityArray.length;i++){
                stringBuilder.append("{"+i + ": group_form_id:" + ((UserGroupFormValueEntity)formValueEntityArray[i]).getGroupFormId() + "\n");
                stringBuilder.append(i + ": value:" + ((UserGroupFormValueEntity)formValueEntityArray[i]).getValue()+"}");
            }

        }
        stringBuilder.append("]");

        return stringBuilder.toString();
    }
}
